
<script setup>
import { ref, computed } from 'vue';
import TabbarTea from "../component/TabbarTea.vue";

const timeRangeIndex = ref(0);
const timeRangeOptions = ["近一个月", "近三个月", "近一年"];

// 模拟签到数据
const signData = ref([
  {
    date: "2024/1/20",
    signTime: "0人",
    batch: "2023年春季放假",
    To:"/pages/user/sign",
  },
  {
    date: "2024/1/19",
    signTime: "0人",
    batch: "2023年春季放假",
    To: "",
  },
  {
    date: "2024/1/18",
    signTime: "0人",
    batch: "2023年春季放假",
    To: "",
  },
  {
    date: "2024/1/17",
    signTime: "0人",
    batch: "2023年春季放假",
    To: "",
  },
]);

const onTimeRangeChange = (e) => {
  timeRangeIndex.value = e.detail.value;
  console.log(`选择了：${timeRangeOptions[timeRangeIndex.value]}`);
};
const Toevent = (item) =>{
  uni.navigateTo({
    url: item.To
  });
};
</script>

<template>
  <view class="sign-page">
    <!-- 右上角时间选择器 -->
    <view class="top-right-selector">
      <picker
          @change="onTimeRangeChange"
          :value="timeRangeIndex"
          :range="timeRangeOptions"
      >
        <view class="picker-view">
          {{ timeRangeOptions[timeRangeIndex] }}
          <image src="/static/arrow-down.png" class="arrow-icon" />
        </view>
      </picker>
    </view>

    <!-- 签到列表 -->
    <view class="sign-list">
      <view
          class="sign-item"
          v-for="(item, index) in signData"
          :key="index"
          @click="Toevent(item)"
      >
        <view class="item-header">
          <image src="/static/clock-icon.png" class="clock-icon" />
          <!-- 签到日期前的图标 -->
          <image class="icon" src="/static/image/bz8@2x.png"></image>
          <text class="sign-date">签到日期：{{ item.date }}</text>
          <!-- 状态仍靠右显示 -->
<!--          <text class="sign-status" :class="{ 'signed': item.status === '已签到', 'unsigned': item.status === '未签到' }">-->
<!--            {{ item.status }}-->
<!--          </text>-->
        </view>
        <view class="item-info">
          <text>校内入住人数：{{ item.signTime }}</text>
          <text>校外入住人数：{{ item.signTime }}</text>
          <text>关联批次：{{ item.batch }}</text>
        </view>
      </view>
    </view>
  </view>
  <view>
    <TabbarTea :cur-index="1"/>
  </view>
</template>

<style scoped>
.sign-page {
  padding: 16px;
  background-color: #f5f7fa;
  min-height: 100vh;
}

.top-right-selector {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.picker-view {
  display: flex;
  align-items: center;
  background-color: #fff;
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  font-size: 12px;
}

.arrow-icon {
  width: 10px;
  height: 10px;
  margin-left: 4px;
}

.sign-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sign-item {
  background-color: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  height: 100px;
}

.item-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 8px;
}

.clock-icon {
  width: 24px;
  height: 24px;
  margin-right: 8px;
}

.icon {
  width: 22px;
  height: 22px;
  margin-right: 8px;
}

.sign-date {
  width: 161px;
  height: 22px;
  font-weight: 500;
  font-size: 16px;
  color: #212121;
}

.sign-status {
  font-size: 14px;
  margin-left: auto;
}

.signed {
  color: green;
}

.unsigned {
  color: red;
}

.item-info {
  display: flex;
  flex-direction: column;
  width: 149px;
  height: 44px;
  font-weight: 400;
  font-size: 12px;
  color: #5D5E5D;
  line-height: 22px;
}
</style>